/*
 * name: mabel xu
 * date: sept 18, 2007
 * filename: HSAthlete.java
 * description: class that creates and manages an HSAthlete
 */

public class HSAthlete implements Comparable
{
	// properties of HSAthletes
	private String nameFirst;
	private String nameLast;
	private int grade;
	private boolean physical;
	private double gpa;

	// simple constructor, only uses first and last name
	public HSAthlete(String f, String l)
	{
		nameFirst = f;
		nameLast = l;
		grade = 0;
		physical = false;
		gpa = 0.0;
	}		// end simple constructor

	// complex constructor, accepts all info
	public HSAthlete(String f, String l, int gr, boolean p, double g)
	{
		nameFirst = f;
		nameLast = l;
		grade = gr;
		physical = p;
		gpa = g;
	}		// end complete constructor

	// pre: HSAthlete already initialized
	// post: returns athlete's first name
	public String getFirstName()
	{
		return nameFirst;
	}		// end of getFirstName() (returns first name)

	// pre: HSAthlete already initialized
	// post: returns athlete's last name
	public String getLastName()
	{
		return nameLast;
	}		// end of getLastName() (returns last name)

	// pre: HSAthlete already initialized
	// post: returns athlete's grade level
	public int getGrade()
	{
		return grade;
	}		// end of getGrade() (returns grade lvl)

	// pre: HSAthlete already initialized
	// post: returns athlete's physical (true or false)
	public boolean currentPhysical()
	{
		return physical;
	}		// end of currentPhysical() (returns physical status)

	// pre: HSAthlete already initialized
	// post: returns athlete's gpa
	public double getGPA()
	{
		return gpa;
	}		// end of getGPA() (returns gpa)

	// pre: HSAthlete initialized
	// post: sets first name to specified first name
	public void setNickName(String f)
	{
		nameFirst = f;
	}		// end of setNickName (sets first name)

	// pre: HSAthlete initialized
	// post: sets gpa to specified gpa
	public void setGPA(double g)
	{
		gpa = g;
	}		// end of setGPA() (sets gpa)

	// pre: HSAthlete initialized
	// post: sets grade level to specified grade lvl
	public void setGrade(int gr)
	{
		grade = gr;
	}		// end of setGrade() (sets grade)

	// pre: HSAthlete initialized and has relevent info
	// post: returns a string formatted with all info (for printing purposes)
	public String toString()
	{
		return nameLast + ", " + nameFirst + " - " +
			"gr = " + grade + ", " +
			"gpa = " + gpa + ", " +
			"physical = " + ( physical ? "yes" : "no" );
	}		// end of toString() (returns athlete info as a formatted string)

	// pre: athlete initialized, passed object is an athlete
	// post: compares to and returns true or false (depending on equal or not)
	public boolean equals(Object o)
	{
		return (nameLast.equals(((HSAthlete)o).getLastName()) &&
			nameFirst.equals(((HSAthlete)o).getFirstName()) &&
			grade == ((HSAthlete)o).getGrade() &&
			physical == ((HSAthlete)o).currentPhysical() &&
			gpa == ((HSAthlete)o).getGPA() ? true : false);
	}		// end of equals() (checks if two athletes equal)

	// pre: athlete initialized, passed object is an athlete
	// post: compares to and returns -, 0, or + # depending on how far apart athletes are (uses Comparable)
	public int compareTo(Object o)
	{
		if (!nameLast.equals(((HSAthlete)o).getLastName()))
			return nameLast.compareTo(((HSAthlete)o).getLastName());
		else if (!nameFirst.equals(((HSAthlete)o).getFirstName()))
			return nameFirst.compareTo(((HSAthlete)o).getFirstName());
		else if (grade != ((HSAthlete)o).getGrade())
			return grade - ((HSAthlete)o).getGrade();
		else if (physical != ((HSAthlete)o).currentPhysical())
			return -1;
		else if (gpa != ((HSAthlete)o).getGPA())
			return (gpa > ((HSAthlete)o).getGPA() ? 1 : -1);
		else
			return 0;
	}		// end of compareTo() (compares two athletes)
}		// end of HSAthlete() class